package me.zhengjie.org.centerbase.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.org.departmentbase.domain.DepartmentBase;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @author ZGZ
* @date 2020-04-15
*/
@Entity
@Data
@Table(name="center_base")
public class CenterBase implements Serializable {

    /** ID */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    /** 所属部门 */
//    @Column(name = "department_id")
//    private Integer departmentId;
//    @OneToOne
//    @JoinColumn(name = "department_id")
//    private DepartmentBase departmentId;
    @Column(name = "department_id")
    private Integer departmentId0;
    @OneToOne
    @JoinColumn(name = "department_id", insertable = false, updatable = false)
    private DepartmentBase departmentId;



    /** 中心名称 */
    @Column(name = "center_name")
    private String centerName;

    /** 创建时间 */
    @Column(name = "start_time")
    private Timestamp startTime;

    /** 撤销时间 */
    @Column(name = "end_time")
    private Timestamp endTime;

    /** 中心描述 */
    @Column(name = "describe_info")
    private String describeInfo;

    public void copy(CenterBase source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}